import { IsString, IsArray, ValidateNested, IsIn } from 'class-validator'
import { Type } from 'class-transformer'
import { ApiProperty } from '@nestjs/swagger'
import { CreateCategoryDto } from './create-category.dto'
import { UpdateCategoryDto } from './update-category.dto'

export class BatchCategoryDto {
  @ApiProperty({ description: '操作类型', enum: ['create', 'update', 'delete'] })
  @IsString()
  @IsIn(['create', 'update', 'delete'])
  operation: 'create' | 'update' | 'delete'

  @ApiProperty({ description: '操作项目列表' })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => Object)
  items: (CreateCategoryDto | UpdateCategoryDto | { id: string })[]
}
